<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    /* 
      当then和catch和finally中如果没有处理当前promise实例状态的回调函数,则直接穿透
    
    */
    const p1 = new Promise((resolve, reject) => {
        try {
          console.log("开始请求A.....")
          throw new Error("网络出现问题!!!!")
          setTimeout(() => {
            console.log("数据请求成功");
            resolve({
              token: "hskahdoqwhdlkash"
            })
          }, 2000)
        } catch (e) {
          reject(e.message)
        }
      })
      .then(value => {
        return 1
      })//穿透 
      .catch(reason => {
        return 2
      })//fulfilled 2
      .then(value => {
        return 3
      })//fulfilled 3
      .catch(reason => {
        return 4
      })//穿透
      console.log(p1);


    const p2 = new Promise((resolve, reject) => {
        resolve(1);
      })
      .then(2)//穿透
      .catch(3)//穿透
      .finally(4)//穿透

    console.log(p2, "p2");
  </script>
</body>

</html>